package org.lex.tinyscript.command;

import java.io.File;

import org.lex.tinyscript.TinyScriptException;
import org.lex.tinyscript.utils.FileOperationUtils;
import org.lex.tinyscript.utils.Loggers;

/**
 * just support file->file move;
 * 
 * @author Daniel Liu
 */
public class MoveFileCommand extends AbstractScriptCommand {
	private File src = null;
	private File dest = null;

	public MoveFileCommand() {
	}

	public void excute() throws TinyScriptException {
		Loggers.getLogger()
				.info("executing move " + this.src + " " + this.dest);
		FileOperationUtils.moveFile(src, dest);
	}

	public String getCommand() {
		return "move";
	}

	public void setArguments(String... files) throws TinyScriptException {
		this.checkArgumentsLength(2, files);
		this.src = new File(files[0]);
		this.dest = new File(files[1]);

		Loggers.getLogger().config("set args: move " + src + " -> " + dest);
	}

	public MoveFileCommand clone() throws CloneNotSupportedException {
		return (MoveFileCommand) super.clone();
	}
}
